<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 *
 * @package    symfony
 * @subpackage plugin
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfGuardValidatorUser.class.php 7904 2008-03-15 13:18:36Z fabien $
 */
class sfMoneyValidator extends sfValidatorBase
{
  public function configure($options = array(), $messages = array())
  {
    $this->setMessage('invalid', 'Valor inválido.');
  }
  

  protected function valueClean ($value)
  {
  	if(strpos($value, ".") === false)
    	$value = str_replace (',','.',$value);
    else
    {
    	$value = str_replace ('.','',$value);
    	$value = str_replace (',','.',$value);
    }
    return $value;
  }

  protected function doClean($values)
  {
  	return $this->valueClean((string)$values);
  }
}
